#!/usr/bin/python3
#coding:utf-8
import time

from selenium import webdriver
mi_up={"ue":"15881034956","pd":"XiongWei723"}

driver=webdriver.Chrome()
driver.get(url="https://account.xiaomi.com/pass/serviceLogin?")
#safari.find_element_by_xpath("//*[@id=\"content\"]/div/div[1]/div/div[2]/a").click()
user=driver.find_element_by_id("username")
user.clear()
user.send_keys(mi_up["ue"])
password=driver.find_element_by_id("pwd")
password.clear()
password.send_keys(mi_up["pd"])
driver.find_element_by_id("login-button").click()
while True:
    try:
        time.sleep(1000)
        driver.get(url="https://item.mi.com/product/10000099.html")
        driver.find_element_by_id("choose-btn-ko").click()
        driver.find_element_by_id("order-submit").click()
        print("抢购成功并且已下单！！")
        driver.quit()
    except Exception:
        print("还未开始抢购！！")


